/**
 * 页面来源，默认从商户平台打开页面
 * 默认值为merchant
 *
 * 1. merchant 商户平台创建流程或编辑流程正常进入
 * 2. sass sass平台流程模板iframe嵌套
 * 3. merchantTemplate merchant平台流程模板
 *
 * @returns {string} 页面来源
 */
export default function useFrom () {
  const {from, merchantTemplateId} = useRoute().query
  const legalFromPosition = ['merchant', 'sass']
  let _from

  if (legalFromPosition.includes(from)) {
    _from = from
  } else if (merchantTemplateId) {
    _from = 'merchantTemplate'
  } else {
    _from = 'merchant'
  }

  return _from
}
